import router from '@/router'
import NProgress from 'nprogress'
import 'nprogress/nprogress.css'
import useDocumentTitle from '@/hook/use-document-title'

const { setTitle } = useDocumentTitle()

NProgress.configure({
  showSpinner: false
})

// vue-router4 的路由守卫不再是通过next放行，而是通过return返回true或false或者一个路由地址
router.beforeEach(to => {
  // 根据路由 设置document.title
  setTitle(to.meta.title)
  return true
})
router.afterEach(() => {
  NProgress.done()
})
